package controller

import (
	"blog_server/global"
	"blog_server/internal/service"
	"blog_server/pkg/app"
	"blog_server/pkg/errcode"
	"github.com/gin-gonic/gin"
)

type AuthorController struct{}

func NewAuthorController() AuthorController {
	return AuthorController{}
}

// Get
// @Tags Author
// @Summary 获取博主信息
// @Schemes
// @Description /blogApi/v1/author
// @Produce json
// @Success 200 {string} string "{"code":0,"data":{},"msg":"ok"}"
// @Router /blogApi/v1/author [get]
func (a AuthorController) Get(c *gin.Context) {
	response := app.NewResponse(c)
	svc := service.New(c.Request.Context())
	author, err := svc.GetAuthor()
	if err != nil {
		global.Logger.Error("GetAuthor error")
		response.ToErrorResponse(errcode.ServerError)
		return
	}
	response.ToSuccessResponse(author)
}
